import React from 'react'
import Title from '../../ReuseTitle'
import AddForm from './UserSetAddForm'
import { connectAddress } from '../../../container/address/connectAddress'

class UserEditAddress extends React.Component {
	constructor(props) {
		super(props)
	}
	componentDidMount() {
		this.props.addressActions.fetchAddress();
	}
	render() {
		const { isFetched, isEdited, isSeted, addressData } = this.props.address;
		const { storeId, addressId } = this.props.params;
		const { editAddress, setDefaultAddress } = this.props.addressActions;
		const data = addressData.filter((item) => item.addressId == addressId);
		return (
            <div>
              <Title title="修改收货地址" />
              <AddForm 
              	edit={true}
              	isEdited={isEdited} 
              	isSeted={isSeted}
              	addressId={addressId} 
              	add_data={data[0]} 
              	storeId={storeId}
              	editAddress={editAddress} 
              	setDefaultAddress={setDefaultAddress}
              />
            </div>
		);
	}
}

export default connectAddress(UserEditAddress)
